package com.srxz.personnelsystem.system.repository;

import com.srxz.personnelsystem.system.entity.Department;
import com.srxz.personnelsystem.util.BackMessage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DepartmentRepository extends JpaRepository<Department, String>,JpaSpecificationExecutor<Department> {
    public Page<Department> findAll(Specification specification, Pageable pageable);

    @Query("from Department where (parentcode is null or parentcode='') and deleteTime is null")
    public List<Department> findAllTop();

    public List<Department> findAllByParentcodeAndDeleteTimeIsNull(String parentcode);

    public List<Department> findAllByDeleteTimeIsNull();
}
